package com.example.sm_project01;

import android.app.Activity;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity;

public class Sms_sending extends SherlockActivity {

	public static final int REQUEST_CODE_SMSSENDING=1002;

	Button sendSMS;
	EditText editPhoneNum;
	EditText editSMS;

	@Override

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);		
		setContentView(R.layout.sms_sending);
		
		// 타이틀바 배경색 바꾸기
				if(getSupportActionBar()!=null){
					ActionBar bar = getSupportActionBar();
					//for color
					bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#005BBB")));
					//for image
					//bar.setBackgroundDrawable(getResources().getDrawable(R.drawable.settings_icon));
				}
		
		
		
		sendSMS = (Button) findViewById(R.id.sendBtn);
		editPhoneNum = (EditText) findViewById(R.id.editPhoneNum);
		editSMS = (EditText) findViewById(R.id.editSMS);
		
		sendSMS.setOnClickListener(new OnClickListener() {
		public void onClick(View v){
			String phoneNo = editPhoneNum.getText().toString();
			String sms = editSMS.getText().toString(); 
			sendMsg(phoneNo, sms);
		}
	});
	}
	
	protected void sendMsg(String phoneNo, String sms){
		SmsManager mysms = SmsManager.getDefault();
		mysms.sendTextMessage(phoneNo, null, sms, null, null);
		Toast.makeText(getApplicationContext(), "SMS Sent!", Toast.LENGTH_LONG).show();
	}



}